<script setup lang='ts'>
  import { onMounted, reactive } from 'vue';
  import { lassoCattleApi } from '@/api/controller';
  import { Toastloading } from '@/utils/public';
  import { getPlayEndTime, getDateArray } from '@/utils'
  const action = reactive({
    list:[] as any[],
    dateArr:getDateArray('ymdhis') as Array<string>
  })
  const listQuery = reactive({
    user_id:'',
    uuid:''
  })
  const resetQuery = ()=>{
    action.dateArr = getDateArray('ymdhis') as Array<string>
    Object.assign(listQuery,{
      user_id:'',
      uuid:''
    })
    getList()
  }
  const getList = async()=> {
    const loading = Toastloading()
    const timeObi = getPlayEndTime(action.dateArr)
    const res = await lassoCattleApi.statUserInfo({
      ...listQuery,
      date_st:timeObi.playTime,
      date_ed:timeObi.endTime
    })
    loading.close()
    const { list=[] } = res?.data || {}
    action.list = list
  }
  onMounted(()=>{
    getList()
  })
</script>

<template>
  <div class="xm-content">
    <div class="labelBox">
      <div class="labelItem">
        <div class="label">用户ID：</div>
        <el-input v-model="listQuery.user_id" placeholder="请输入用户ID" ></el-input>
      </div>
      <div class="labelItem">
        <div class="label">用户UUID：</div>
        <el-input v-model="listQuery.uuid" placeholder="请输入用户UUID" ></el-input>
      </div>
      <div class="labelItem">
        <div class="label">时间：</div>
        <el-date-picker
          v-model="action.dateArr"
          type="datetimerange"
          format="YYYY-MM-DD HH:mm:ss"
          value-format="YYYY-MM-DD HH:mm:ss"
          range-separator="至"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
        />
      </div>
      <div class="labelItem">
        <el-button type="primary" @click="getList">查询</el-button>
        <el-button type="primary" @click="resetQuery">重置</el-button>
      </div>
    </div>
    <el-table
      class="xm-TableCenter"
      :data="action.list"
      border>
      <el-table-column min-width="120" prop="userId" label="用户ID" />
      <el-table-column min-width="120" prop="uuid" label="用户UUID" />
      <el-table-column min-width="120" prop="nickname" label="用户昵称" />
      <el-table-column min-width="120" prop="joinNum" sortable label="参与次数" />
      <el-table-column min-width="120" prop="stakeNumAll" sortable label="参与次数" />
      <el-table-column min-width="120" prop="stakeNum" sortable label="成功次数"/>
      <el-table-column min-width="120" prop="stakePriceAll" sortable label="消耗金豆数量" />
      <el-table-column min-width="120" prop="rewardPriceAll" sortable label="产出金豆数量" />
      <el-table-column min-width="120" prop="porfitNum" sortable label="利润金豆数量" />
      <el-table-column min-width="120" prop="porfitRate" label="利润率" />
      <el-table-column min-width="120" prop="buyGiftJdNum" sortable label="兑换幸运券金豆数量" />
    </el-table>
  </div>
</template>
